package com.yang.designmode.proxy.dynamicProxy.CGLIBDynamicProxy;

import net.sf.cglib.proxy.Enhancer;

public class CglibProxyDemo {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(UserService.class); // 设置父类
        enhancer.setCallback(new MyMethodInterceptor()); // 设置拦截器

        UserService proxy = (UserService) enhancer.create(); // 创建代理对象
        proxy.addUser(); // 调用方法，触发拦截逻辑
    }
}
